package com.ai.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ai.web.cache.Constants;
import com.ai.web.service.CompanyProfileService;
import com.ai.web.vo.CompanyProfileV;
import com.ai.web.vo.ResultModel;
/**
 * 公司简介
* @ClassName: CompanyProfileController 
* @Description: TODO 
* @author:  
* @date: 2014年3月24日
*
 */
@Controller
@RequestMapping("/companyProfile")
public class CompanyProfileController extends BaseController {
    

    private static Logger logger = Logger.getLogger(CompanyProfileController.class);
    
    @Autowired
    private CompanyProfileService companyProfileService;
    
    @RequestMapping(value = "/update", produces = "application/json")
    public String updatecompanyProfile(@RequestParam HashMap<String, Object> paramMap, Model model)
            throws Exception {
    	paramMap.put(Constants.KEY_PAGE_FROM, 1);
    	Map<String, Object> conditionMap = buildCondition(paramMap);
    	@SuppressWarnings("unchecked")
		List<CompanyProfileV> companyProfileVs = (List<CompanyProfileV>)companyProfileService.queryListAndCount(conditionMap).getDataList();
    	CompanyProfileV companyProfileV = new CompanyProfileV();
    	if(companyProfileVs.size() > 0){
    		companyProfileV = companyProfileVs.get(0);
        }
    	logger.info("----- getUser:" + companyProfileV);
        
        model.addAttribute(companyProfileV);
        
        return "companyProfile/companyProfile_template";
    }
    
    @RequestMapping(value = "/save", produces = "application/json")
    @ResponseBody
    public ResultModel savecompanyProfile(CompanyProfileV companyProfileV) throws Exception {
        
        ResultModel rm = companyProfileService.saveCompanyProfile(companyProfileV);
        
        return rm;
    }
    
}
